package com.jianganming.state.pay;

//下单
public class PlaceOrderState implements IState {
    private Context context = Context.getContext();

    private IState iState;

    public PlaceOrderState(IState iState) {
        if(iState instanceof PayOrderState || iState instanceof CancelOrderState){
            this.iState = iState;
        }else {
            throw new RuntimeException("下一个环节是支付或者取消订单");
        }

    }

    @Override
    public void doAction(Order order) {
        System.out.println("下单成功，订单号："+order.getOrderNumber()+" 商品："+order.getProductName());
        context.addOrderState(OrderState.place_order);
        iState.doAction(order);//调用下一个环节
    }
}
